package moe.launch;

import java.util.logging.LogManager;

import moe.collection.CollectionScanner;
import moe.config.Configuration;
import moe.config.Constants;
import moe.server.MoeServer;

public class Launcher {
	private MoeServer server;
	private CollectionScanner collectionScanner;

	public void startup() {
		try {
			LogManager.getLogManager().readConfiguration(
					ClassLoader.getSystemResourceAsStream(Constants.LOGGING_CONF_FILE));
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		server = new MoeServer();
		collectionScanner = new CollectionScanner();

		if (Configuration.isOpenBrowser()) {
			Browser.open();
		}
		collectionScanner.listen();
		server.startup();
	}

	public void shutdown() {
		collectionScanner.shutdown();
		server.shutdown();
	}
}
